package com.code.qgjx.service.impl;

import com.code.qgjx.entity.WorkPush;
import com.code.qgjx.mapper.WorkPushMapper;
import com.code.qgjx.service.WorkPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class WorkPushServiceImpl implements WorkPushService {

    @Autowired
    private WorkPushMapper workPushMapper;

    @Override
    public boolean createWorkPush(WorkPush workPush) {
        return workPushMapper.insert(workPush) > 0;
    }

    @Override
    public boolean deleteWorkPush(Long id) {
        return workPushMapper.deleteById(id) > 0;
    }

    @Override
    public boolean updateWorkPush(WorkPush workPush) {
        return workPushMapper.update(workPush) > 0;
    }

    @Override
    public Map<String, Object> getWorkPush(Long id) {
        return workPushMapper.selectById(id);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByYearAndSemester(String year, String semester) {
        return workPushMapper.selectByYearAndSemester(year, semester);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByDepartment(String departmentName) {
        return workPushMapper.selectByDepartment(departmentName);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByState(Integer state) {
        return workPushMapper.selectByState(state);
    }

    @Override
    public boolean approveWorkPush(Long id, Integer state, String remark) {
        WorkPush workPush = new WorkPush();
        workPush.setId(id);
        workPush.setState(state);
        workPush.setRemark(remark);
        return workPushMapper.update(workPush) > 0;
    }

    @Override
    public List<Map<String, Object>> getAllWorkPush() {
        return workPushMapper.selectAll();
    }

    @Override
    public List<Map<String, Object>> getAllWorkPushWithPage(int start, int limit, String userId, String status) {
        return workPushMapper.selectAllWithPage(start, limit, userId,status);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByYearAndSemesterWithPage(String year, String semester, int start, int limit, String userId) {
        return workPushMapper.selectByYearAndSemesterWithPage(year, semester, start, limit, userId);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByDepartmentWithPage(String departmentName, int start, int limit, String userId) {
        return workPushMapper.selectByDepartmentWithPage(departmentName, start, limit, userId);
    }

    @Override
    public List<Map<String, Object>> getWorkPushByStateWithPage(Integer state, int start, int limit, String userId) {
        return workPushMapper.selectByStateWithPage(state, start, limit, userId);
    }

    @Override
    public int getWorkPushCount(String userId) {
        return workPushMapper.selectCount(userId);
    }

    @Override
    public int getWorkPushCountByYearAndSemester(String year, String semester, String userId) {
        return workPushMapper.selectCountByYearAndSemester(year, semester, userId);
    }

    @Override
    public int getWorkPushCountByDepartment(String departmentName, String userId) {
        return workPushMapper.selectCountByDepartment(departmentName, userId);
    }

    @Override
    public int getWorkPushCountByState(Integer state, String userId) {
        return workPushMapper.selectCountByState(state, userId);
    }

    @Override
    public List<Map<String, Object>> searchWorkPush(WorkPush searchWorkPush, int start, int limit) {
        return workPushMapper.searchWorkPush(searchWorkPush, start, limit);
    }

    @Override
    public int getSearchWorkPushCount(WorkPush searchWorkPush) {
        return workPushMapper.getSearchWorkPushCount(searchWorkPush);
    }
} 